home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <pharlap.h>
- #include <pldos32.h>
- #ifdef __HIGHC__
- #include <dos.h>
- #endif
- #include "exc.h"
-
- static char * progName;
-
- void Execute(char *path,char *args)
- {
- union _REGS r;
- EXEC_BLK blk;
- char buf[150],len;
- ULONG minPages,maxPages;
-
- _dx_cmem_limit(4,&minPages,&maxPages);
-
- strcpy(&buf[1],args);
- len = strlen(args);
- buf[0] = len++;
- buf[len] = 13;
-
- blk.ex_eseg = 0; /* inherit environment */
- blk.ex_coff = buf; /* command line address */
- blk.ex_cseg = SS_DATA;
- r.x.ax = 0x4B00;
- r.x.bx = (UINT)&blk;
- r.x.dx = (UINT)path;
- _intdos(&r,&r);
- if (r.x.cflag & 1)
- printf("Cannot execute child. Error-code %X\n",r.h.al);
- }
-
- void DemoExcHook (excReg *r)
- {
- char buf[150];
- sprintf(buf," /c echo g %04X | 386debug %s",r->EIP,progName);
- Execute(getenv("COMSPEC"),buf);
- exit(1);
- }
-
- /*-------------------------------------------------*/
-
- int main (int argc, char **argv)
- {
- char *p = (char*)-1;
-
- if (strcmp("-postdebug",argv[1]) == 0)
- {
- progName = argv[0];
- InstallExcHandler (DemoExcHook,0);
- }
- *p = 0; /* Causes a crash, exception handler executes debugger */
- /* and cause a new crash here (exception 13) */
- return 0;
- }
-
-
-